/*******************************************************************************
 *
 *    Copyright (c) Baina Info Tech Co. Ltd
 *
 *    AndroidSDK
 *    
 *    QuickBageTest
 *    TODO File description or class description.
 *
 *    @author: zuochen
 *    @since:  2011-6-16
 *    @version: 1.0
 *
 ******************************************************************************/

package com.sdk.view.quickbage;

import android.app.Activity;
import android.graphics.Rect;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

import com.android.sdk.R;

/**
 * QuickBageTest of AndroidSDK.
 * 
 * @author zuochen
 * 
 */

public class QuickBageTest extends Activity {
	/*
	 * (non-Javadoc)
	 * 
	 * @see android.app.Activity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		final Button findViewById = (Button) findViewById(R.id.Button01);
		findViewById.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				final int[] xy = new int[2];
				v.getLocationInWindow(xy);
				Log.d("C345Assignment1", "x: " + xy[0] + "; y: " + xy[1]);
				final Rect rect = new Rect(xy[0], xy[1], xy[0] + v.getWidth(),
						xy[1] + v.getHeight());

				// Create QuickAction component (custom Popup for selection:
				// QuickActionWindow.java)
				// The component require the position of the view calling it to
				// know where to place the popup
				final QuickActionWindow qa = new QuickActionWindow(
						QuickBageTest.this, v);

				// Add "View" item and assign the listener on event it's being
				// clicked
				qa.addItem(
						getResources().getDrawable(
								android.R.drawable.ic_menu_mapmode),
						R.string.app_name, new OnClickListener() {
							@Override
							public void onClick(View v) {
								Toast.makeText(QuickBageTest.this, "",
										Toast.LENGTH_SHORT).show();
								qa.dismiss();
							}
						});
				qa.addItem(
						getResources().getDrawable(
								android.R.drawable.ic_menu_mapmode),
						R.string.app_name, new OnClickListener() {
							@Override
							public void onClick(View v) {
								Toast.makeText(QuickBageTest.this, "",
										Toast.LENGTH_SHORT).show();
								qa.dismiss();
							}
						});
				qa.addItem(
						getResources().getDrawable(
								android.R.drawable.ic_menu_mapmode),
						R.string.app_name, new OnClickListener() {
							@Override
							public void onClick(View v) {
								Toast.makeText(QuickBageTest.this, "",
										Toast.LENGTH_SHORT).show();
								qa.dismiss();
							}
						});
				qa.addItem(
						getResources().getDrawable(
								android.R.drawable.ic_menu_mapmode),
						R.string.app_name, new OnClickListener() {
							@Override
							public void onClick(View v) {
								Toast.makeText(QuickBageTest.this, "",
										Toast.LENGTH_SHORT).show();
								qa.dismiss();
							}
						});
				qa.addItem(
						getResources().getDrawable(
								android.R.drawable.ic_menu_mapmode),
						R.string.app_name, new OnClickListener() {
							@Override
							public void onClick(View v) {
								Toast.makeText(QuickBageTest.this, "",
										Toast.LENGTH_SHORT).show();
								qa.dismiss();
							}
						});
				qa.addItem(
						getResources().getDrawable(
								android.R.drawable.ic_menu_mapmode),
						R.string.app_name, new OnClickListener() {
							@Override
							public void onClick(View v) {
								Toast.makeText(QuickBageTest.this, "",
										Toast.LENGTH_SHORT).show();
								qa.dismiss();
							}
						});
				qa.show();
			}
		});
	}
}
